package com.example.seed.handler;

import io.jsonwebtoken.security.SignatureException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(SignatureException.class)
    public ResponseEntity<Object> handleException(SignatureException e) {
        return ResponseEntity.badRequest().body(e.getMessage());
    }


    /**
     * 兜底异常
     *
     * @param e e
     * @return {@link ResponseEntity}<{@link Object}>
     */
    @ExceptionHandler(Exception.class)
    public ResponseEntity<Object> exception(Exception e) {
        e.printStackTrace();
        return ResponseEntity.badRequest().body(e.getMessage());
    }

}
